home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / MacApp C++ Load⁄dump / DemoTextDump 2 / UDemoText.h < prev   
Encoding:
C/C++ Source or Header  |  1992-07-15  |  3.4 KB  |  117 lines  |  [TEXT/MPS ]

  1. /* Copyright © 1989 - 1990 by Apple Computer, Inc. All rights reserved. */
  2. /* UDemoText.p */
  3.  
  4.  
  5. /*
  6.     This sample application demonstrates the breadth of alternatives
  7.     available when using the MacApp building-block "UTEView" for text-editing.
  8. */
  9.  
  10. #ifndef __DemoTextDump__
  11. #include "DemoTextDump.h"
  12. #endif
  13.  
  14.  
  15.  
  16. #define qDebug TRUE
  17.  
  18. const unsigned long kSignature            = 'SS04';        /* application signature */
  19. const unsigned long kFileType            = 'TEXT';        /* file-type code for saved disk files --
  20.                                                           uses standard text files */
  21. const short kWindowRsrcID        = 1004;                    /* 'view' template for a DemoText window */
  22. const short kViewRsrcID            = 1005;                    /* 'view' template for a DemoText view */
  23.  
  24.                                                         /* Additional document specifications */
  25. struct TextSpecs {
  26.     Str255 theTextFont;
  27.     Style theTextFace;
  28.     short theTextSize;
  29.     RGBColor theTextColor;
  30.     short theJustification;                                /* record justification */
  31.     RGBColor theBackColor;                                /* Window's background color */
  32. };
  33. typedef TextSpecs *TextSpecsPtr;
  34. typedef TextSpecsPtr *TextSpecsHdl;
  35.  
  36. class TDemoTextApplication : public TApplication {
  37.   public:
  38.  
  39.     virtual pascal void IDemoTextApplication(void);
  40.                 /* Initialize the Application */
  41.  
  42.     virtual pascal TDocument *DoMakeDocument(CmdNumber itsCmdNumber);
  43.                 /* Launches a TTextDocument */
  44.  
  45. #if  qDebug
  46.     virtual pascal void IdentifySoftware(void);
  47. #endif
  48.  
  49. };
  50.  
  51. class TTextDocument : public TDocument {
  52.   public:
  53.  
  54.     Handle fDocText;                                    /* The text owned by the document */
  55.     TEStyleHandle fStyles;                                /* Style handle, if any */
  56.     STHandle fElements;                                    /* Handle to element array, if any */
  57.     TTEView *fTEView;                                    /* The view which displays the text */
  58.  
  59.     TextSpecs fTextSpecs;                                /* Specifies properties of the text */
  60.  
  61.                         /* Initialization and freeing */
  62.  
  63.     virtual pascal void ITextDocument(void);
  64.     virtual pascal void Free(void);
  65.     virtual pascal void DoInitialState(void);
  66.     virtual pascal void FreeData(void);
  67.  
  68.                         /* Filing */
  69.  
  70.     virtual pascal void DoNeedDiskSpace(long *dataForkBytes, long *rsrcForkBytes);
  71.     virtual pascal void DoRead(short aRefNum, Boolean rsrcExists, Boolean forPrinting);
  72.     virtual pascal void DoWrite(short aRefNum, Boolean makingCopy);
  73.  
  74.                         /* Making views and windows */
  75.  
  76.     virtual pascal void DoMakeViews(Boolean forPrinting);
  77.  
  78.                         /* Command processing */
  79.  
  80.     virtual pascal TCommand *DoMenuCommand(CmdNumber aCmdNumber);
  81.     virtual pascal void DoSetupMenus(void);
  82.  
  83.                         /* Auxiliary routines */
  84.  
  85.     virtual pascal void ChangeBackColor(RGBColor *newColor);
  86.  
  87.     virtual pascal void SetSpecStyle(void);
  88.  
  89.     virtual pascal void ShowReverted(void);
  90.                 /* When the user reverts a document, this is called after reading
  91.                   the old document and before displaying it. Causes the reverted
  92.                   font specs to be installed. */
  93.  
  94.                 /* Debugging */
  95.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  96.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  97.  
  98. };
  99.  
  100. class TJustCommand : public TCommand {
  101.   public:
  102.     TTEView *fTEView;
  103.     short fOldJust;
  104.     short fNewJust;
  105.  
  106.     virtual pascal void IJustCommand(TTEView *itsTEView, short itsNewJust);
  107.  
  108.     virtual pascal void DoIt(void);
  109.  
  110.     virtual pascal void RedoIt(void);
  111.  
  112.     virtual pascal void UndoIt(void);
  113.  
  114.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  115.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  116. };
  117.